<?php
include __DIR__."/Solution.php";

/**
 * Created by PhpStorm.
 * User: Sage
 * Date: 2019/4/11
 * Time: 11:06
 */
class SolutionTest extends  \PHPUnit\Framework\TestCase {


    /**
     * @param mixed ...$params
     * @dataProvider dataProvider
     */
    function testSolution(...$params){
        $answer=array_pop($params);
        $this->assertEquals($answer,(new Solution)->isSubtree(...$params));
    }

    function dataProvider(){

        return [
            [
                Solution::genNode(3,Solution::genNode(4,Solution::genNode(1),Solution::genNode(2)),Solution::genNode(5)),
                Solution::genNode(4,Solution::genNode(1),Solution::genNode(2)),
                true
            ],
            [
                Solution::genNode(3,Solution::genNode(4,Solution::genNode(1),Solution::genNode(2,Solution::genNode(0))),Solution::genNode(5)),
                Solution::genNode(4,Solution::genNode(1),Solution::genNode(2)),
                false
            ],
            [
                Solution::genNode(1,Solution::genNode(1)),
                Solution::genNode(1),
                true
            ],
            [
                Solution::genNode(3,Solution::genNode(4,Solution::genNode(1,Solution::genNode(0)),Solution::genNode(2)),Solution::genNode(5)),
                Solution::genNode(4,Solution::genNode(1),Solution::genNode(2)),
                false
            ],
            [
                Solution::genNode(3,Solution::genNode(4,Solution::genNode(1)),Solution::genNode(5,Solution::genNode(2))),
                Solution::genNode(3,Solution::genNode(1),Solution::genNode(2)),
                false
            ],
        ];
    }

}



